﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace ClassLibrary.Realization
{
    /// <summary>
    /// 除法
    /// </summary>
    public class Division : ICalculation
    {
        public double firstDigits { get; set; }//第一位数

        public double secondDigits { get; set; }//第二位数
        public int firstDigit { get ; set ; }
        public int secondDigit { get; set ; }

        public List<string> Value = new List<string>();
        public List<string> RunValue()
        {
            return Value;
        }
        Random rd = new Random();
        public List<string> RunAll(int count)
        {
            return FourOperations(count, out string value);
        }
        public List<string> FourOperations(int count, out string value)
        {
            string t = "";
            value = null;
            List<string> vs = new List<string>();
            for (int i = 0; i < count; i++)
            {
                firstDigits = rd.Next(1, 11);
                secondDigits = rd.Next(1, 11);
                if (firstDigits != 0 && firstDigits > secondDigits)
                {
                    t = $"{ firstDigits}/{secondDigits}=？";
                    if (firstDigits % secondDigits == 0)
                    {
                        value = (firstDigits / secondDigits).ToString();
                    }
                    else
                    {
                        value = (firstDigits / secondDigits).ToString("f2");

                    }
                }
                else
                {
                    if (secondDigits != 0)
                    {
                        t = $"{secondDigits}/{firstDigits}=？";

                        if (secondDigits % firstDigits == 0)
                        {
                            value = (secondDigits / firstDigits).ToString();
                        }
                        else
                        {
                            value = (secondDigits / firstDigits).ToString("f2");

                        }

                    }
                    else
                    {
                        return null;
                    }
                }
                vs.Add(t);
                Value.Add(value);
            }
            return vs;
        }
        //public void results()//统计结果！
        //{
        //    Console.WriteLine($"总共做了{rightNumber + wrongnumber}道题：你做对了{rightNumber}道题,做错了{wrongnumber}道题。");
        //}
    }
}
